package com.a16.yuejian.yuejian.fragment;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.a16.yuejian.yuejian.R;
import com.a16.yuejian.yuejian.activity.ClubVideoActivity;
import com.a16.yuejian.yuejian.activity.SerachActivity;
import com.a16.yuejian.yuejian.adapter.ClubVideoAdapter;
import com.a16.yuejian.yuejian.javabean.Video;
import com.a16.yuejian.yuejian.listener.Listener;
import com.a16.yuejian.yuejian.model.ClubModel;

import java.util.List;


public class ClubVideoFragment extends Fragment {
    private ImageView club_videoimg;
    private View view=null;
    private RecyclerView recyclerview;

    Listener<List<Video>> listener = new Listener<List<Video>>() {
        @Override
        public void onResponse(List<List<Video>> t) {
            recyclerview.setAdapter(new ClubVideoAdapter(getActivity(),t));
        }

        @Override
        public void onFail() {

        }
    };

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
        view=inflater.inflate(R.layout.clubvideo_fragment, container, false);
        initRecyclerView(view);
        getData();
        return view;
    }

    private void getData() {
        ClubModel clubModel = new ClubModel();
        clubModel.getclubvideo(listener);

    }

    private void initRecyclerView(View view) {
        recyclerview = (RecyclerView)view.findViewById(R.id.club_video);
        recyclerview.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    }
}
